/*
* @Author: An
* @Date:   2017-07-15 14:08:32
* @Last Modified by:   An
* @Last Modified time: 2017-07-16 13:42:44
*/

'use strict';
var _xj = require('util/xj.js');

var _address = {
	// 获取地址列表
	getAddressList : function(resolve, reject) {
		_xj.request({
			url 	: _xj.getServerUrl('/shipping/list.do'),
			data	: {
				pageSize : 50
			},
			method 	: 'POST',
			success : resolve,
			error 	: reject 
		});
	},
	// 保存收货地址
	save : function(addressInfo, resolve, reject) {
		_xj.request({
			url 	: _xj.getServerUrl('/shipping/add.do'),
			data	: addressInfo,
			method 	: 'POST',
			success : resolve,
			error 	: reject 
		});
	},
	// 更新收货地址
	update : function(addressInfo, resolve, reject) {
		_xj.request({
			url 	: _xj.getServerUrl('/shipping/update.do'),
			data	: addressInfo,
			method 	: 'POST',
			success : resolve,
			error 	: reject 
		});
	},
	// 删除收货地址
	deleteAddress : function(shippingId, resolve, reject) {
		_xj.request({
			url 	: _xj.getServerUrl('/shipping/del.do'),
			data	: {
				shippingId : shippingId
			},
			method 	: 'POST',
			success : resolve,
			error 	: reject 
		});
	},
	// 获取单条收件人信息
	getAddress : function(shippingId, resolve, reject) {
		_xj.request({
			url 	: _xj.getServerUrl('/shipping/select.do'),
			data	: {
				shippingId  : shippingId
			},
			method 	: 'POST',
			success : resolve,
			error 	: reject 
		});
	}
}
module.exports = _address;